from django.db import models

# Create your models here.
#base
# class base(models.Model):
#     class Meta:
#         db_table = 'base'
#         verbose_name = '基类'
#         verbose_name_plural = '基类'
#     id = models.AutoField(primary_key=True,default=0)
#     createdate = models.DateTimeField(null=True)
#     updatedate = models.DateTimeField(null=True)
#     isdelete = models.BooleanField(default=False)
#     deleteddate = models.DateTimeField(null=True)
#     base_ptr=models.IntegerField(unique=True)
#     pass
#用户
class User(models.Model):
    class Meta:
        db_table = 'User'
        verbose_name = '用户表'
        verbose_name_plural = '用户表'
    id = models.AutoField(primary_key=True,default=0)
    createdate = models.DateTimeField(null=True)
    updatedate = models.DateTimeField(null=True)
    isdelete = models.BooleanField(default=False)
    deleteddate = models.DateTimeField(null=True)
    name=models.CharField(max_length=20,null=False)
    image=models.ImageField(width_field=50,height_field=50,null=True)
    mobilphineno=models.CharField(max_length=13,default='')
    mobilphinepwd=models.CharField(max_length=20,default='')
    lastLoginTime=models.DateTimeField()
    email=models.EmailField(max_length=20)
    emailpwd=models.CharField(max_length=20,default='')
    emailverifyurl=models.CharField(max_length=200,default='')#邮箱验证链接
    wechatid=models.CharField(max_length=50,default='')
    qqid=models.CharField(max_length=50,default='')
    weibo=models.CharField(max_length=50,default='')
    csdn=models.CharField(max_length=50,default='')
    status=models.CharField(max_length=5,default='0')
    fromInvitationcode=models.CharField(max_length=15,default='')#邀请码
    Invitationcode=models.CharField(max_length=15,null=True,default='')#我的邀请码
    beskilledin=models.CharField(max_length=50,default='')#擅长的领域2
    accumulatepoints=models.CharField(max_length=5,default=0)#积分

#文章标签 技术领域
class Tag(models.Model):
    class Meta:
        db_table = 'Tag'
        verbose_name = '类别表'
        verbose_name_plural = '技术领域'
    id = models.AutoField(primary_key=True,default=0)
    createdate = models.DateTimeField(null=True)
    updatedate = models.DateTimeField(null=True)
    isdelete = models.BooleanField(default=False)
    deleteddate = models.DateTimeField(null=True)
    belongto=models.IntegerField()#上一级 最多3级,值为-1时不属于任何级
    tagname=models.TextField(max_length=10)

#文章
class Article(models.Model):
    class Meta:
        db_table = 'Article'
        verbose_name = '文章'
        verbose_name_plural = '文章'
    id = models.AutoField(primary_key=True,default=0)
    createdate = models.DateTimeField(null=True)
    updatedate = models.DateTimeField(null=True)
    isdelete = models.BooleanField(default=False)
    deleteddate = models.DateTimeField(null=True)
    title=models.TextField(max_length=50)
    author=models.ForeignKey(User,related_name="user_set",on_delete=models.CASCADE)
    Money_reward=models.CharField(max_length=5)#赏金
    deposit=models.BooleanField()#是否赏金已托管
    content=models.TextField(max_length=8000)
    status=models.CharField(max_length=5,default=0)
    type=models.ForeignKey(Tag,related_name="Tagtype_set",on_delete=models.CASCADE)#主题ID
    tag0=models.TextField(max_length=10)
    tag1=models.TextField(max_length=10)
    tag2=models.TextField(max_length=10)
    tag3=models.TextField(max_length=10)
    tag4=models.TextField(max_length=10)

#私信
class Message(models.Model):
    class Meta:
        db_table = 'Message'
        verbose_name = '私信'
        verbose_name_plural = '私信'
    id = models.AutoField(primary_key=True,default=0)
    createdate = models.DateTimeField(null=True)
    updatedate = models.DateTimeField(null=True)
    isdelete = models.BooleanField(default=False)
    deleteddate = models.DateTimeField(null=True)
    author = models.ForeignKey(User, related_name="user_message", on_delete=models.CASCADE)
    content = models.TextField(max_length=500)
    readdate= models.DateTimeField()
    status = models.CharField(max_length=5,default=0)
    isread=models.BooleanField()
    pass

#评论
class comment(models.Model):
    class Meta:
        db_table = 'comment'
        verbose_name = '评论'
        verbose_name_plural = '评论'
    id = models.AutoField(primary_key=True,default=0)
    createdate = models.DateTimeField(null=True)
    updatedate = models.DateTimeField(null=True)
    isdelete = models.BooleanField(default=False)
    deleteddate = models.DateTimeField(null=True)
    articleid=models.ForeignKey(Article,related_name="article_comment",on_delete=models.CASCADE)#主题ID
    topic_type= models.TextField(max_length=50)
    #主题type
    content = models.TextField(max_length=500)
    #评论内容
    from_uid=models.ForeignKey(User,related_name="fromuser_set",on_delete=models.CASCADE)
    #评论用户id
    to_uid=models.ForeignKey(User,related_name="touser_set",on_delete=models.CASCADE)
    #评论目标用户id
    status = models.CharField(max_length=5,default=0)
    pass
#积分历史记录
class accumulatepoints_history(models.Model):
    class Meta:
        db_table = 'accumulatepoints_history'
        verbose_name = '积分历史记录'
        verbose_name_plural = '积分历史记录'
    id = models.AutoField(primary_key=True,default=0)
    createdate = models.DateTimeField(null=True)
    updatedate = models.DateTimeField(null=True)
    isdelete = models.BooleanField(default=False)
    deleteddate = models.DateTimeField(null=True)
    uid = models.ForeignKey(User, related_name="accumulate_set", on_delete=models.CASCADE)  # 评论用户id
    point=models.CharField(max_length=5,default=0)
    pass

#点赞 踩历史记录
class praise_or_notpraise(models.Model):
    class Meta:
        db_table = 'praise_or_notpraise'
        verbose_name = '点赞 踩历史记录'
        verbose_name_plural = '点赞 踩历史记录'
    id = models.AutoField(primary_key=True,default=0)
    createdate = models.DateTimeField(null=True)
    updatedate = models.DateTimeField(null=True)
    isdelete = models.BooleanField(default=False)
    deleteddate = models.DateTimeField(null=True)
    topicid = models.IntegerField()
    type=models.CharField(max_length=5,default=0)#1文章,2评论
    from_uid=models.ForeignKey(User,related_name="userpraise",on_delete=models.CASCADE)
    praise=models.CharField(max_length=5,default=0)#1点赞,2踩
    pass

#交易历史记录
class moneyHistory(models.Model):
    class Meta:
        db_table = 'moneyHistory'
        verbose_name = '交易历史记录'
        verbose_name_plural = '交易历史记录'
    id = models.AutoField(primary_key=True,default=0)
    createdate = models.DateTimeField(null=True)
    updatedate = models.DateTimeField(null=True)
    isdelete = models.BooleanField(default=False)
    deleteddate = models.DateTimeField(null=True)
    topic_id=models.ForeignKey(Article,related_name="topicid",on_delete=models.CASCADE)  #主题ID
    topic_type= models.TextField(max_length=50)#主题type
    content = models.TextField(max_length=500)#评论内容
    from_uid=models.ForeignKey(User,related_name="mfromuser_set",on_delete=models.CASCADE)#评论用户id
    to_uid=models.ForeignKey(User,related_name="mtomuser_set",on_delete=models.CASCADE)
    plat=models.CharField(max_length=20,default=0)#平台,支付宝,微信
    pass